package io.zhengsh.vvip.leetcode.dp;

public class Q413__ {

    class Solution {
        public int numberOfArithmeticSlices(int[] nums) {
            int len = nums.length;
            if (len < 3) {
                return 0;
            }
            int d = nums[1] - nums[0], t = 0, ans = 0;
            for (int i = 2; i < len; i++) {
                if (nums[i] - nums[i - 1] == d) {
                    t++;
                } else {
                    d = nums[i] - nums[i - 1];
                    t = 0;
                }
                ans += t;
            }
            return ans;
        }
    }
}
